{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "egyptian-transformation",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import re\n",
    "import lux\n",
    "headers=['title','author','publisher','publishTime','price','rate','commentsNum']\n",
    "#bookDf = pd.read_csv(\"douban_book.csv\")\n",
    "bookDf = pd.read_csv('douban_book.csv', delimiter=',', encoding='utf-8',names=headers)\n",
    "bookDf['price'] = bookDf['price'].map(lambda price: re.findall(r\"\\d+\\.?\\d*\",price)[0] )\n",
    "bookDf['commentsNum'] = bookDf['commentsNum'].map(lambda commentsNum: re.findall(r\"\\d+\\.?\\d*\",commentsNum)[0] )\n",
    "print(bookDf)\n",
    "bookDf.to_csv (\"douban_book_new.csv\" , encoding = \"utf-8\")\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
